package com.mspbots.api.client;

import com.fasterxml.jackson.databind.JsonNode;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Map;

/**
 * com.mspbots.web.BaseWebClient
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2019/8/26
 */
public interface BaseClient {

    /**
     * http post object
     *
     * @param path         http post path
     * @param body         post body  params
     * @param responseType post return class type
     * @return mono data result
     */
    <T> Mono<T> post(String path, Object body, Class<T> responseType);

    /**
     * http post flux object
     *
     * @param path         http post path
     * @param body         post body  params
     * @param responseType post return class type
     * @return mono data result flux
     */
    <T> Flux<T> postFlux(String path, Object body, Class<T> responseType);

    /**
     * http post flux object
     *
     * @param path http post path
     * @param body post body  params
     * @return flux default return type class  JsonNode
     */
    default Flux<JsonNode> postFlux(String path, Object body) {
        return postFlux(path, body, JsonNode.class);
    }

    /**
     * http post object
     *
     * @param path http post path
     * @param body post body  params
     * @return default return type class JsonNode
     */
    default Mono<JsonNode> post(String path, Object body) {
        return post(path, body, JsonNode.class);
    }

    /**
     * http put object
     *
     * @param path         http put path
     * @param body         put params
     * @param responseType return data data type
     * @return mono data result
     */
    <T> Mono<T> put(String path, Object body, Class<T> responseType);

    /**
     * http put object
     *
     * @param path http put path
     * @param body put body
     * @return default return type class Integer,
     */
    default Mono<JsonNode> put(String path, Object body) {
        return put(path, body, JsonNode.class);
    }

    /**
     * http delete object
     *
     * @param path         http delete path
     * @param params       delete params
     * @param responseType return data data type
     * @return mono data result
     */
    <T> Mono<T> delete(String path, Map<String, Object> params, Class<T> responseType);

    /**
     * http delete object
     *
     * @param path   http delete path
     * @param params delete params
     * @return default return type class Integer,
     */
    default Mono<JsonNode> delete(String path, Map<String, Object> params) {
        return delete(path, params, JsonNode.class);
    }

    /**
     * http get object
     *
     * @param path         http get path
     * @param params       get params
     * @param responseType return data get class type
     * @return mono data result
     */
    <T> Mono<T> get(String path, Map<String, Object> params, Class<T> responseType);

    /**
     * http get object collections
     *
     * @param path         http get path
     * @param params       get params
     * @param responseType return data get class collections type
     * @return mono data result
     */
    <T> Flux<T> getFlux(String path, Map<String, Object> params, Class<T> responseType);

    /**
     * http get object
     *
     * @param path   http get path
     * @param params get data query params
     * @return default return type class JsonNode
     */
    default Mono<JsonNode> get(String path, Map<String, Object> params) {
        return get(path, params, JsonNode.class);
    }

    /**
     * http get flux object
     *
     * @param path   http get path
     * @param params get data query params
     * @return default return type class JsonNode
     */
    default Flux<JsonNode> getFlux(String path, Map<String, Object> params) {
        return getFlux(path, params, JsonNode.class);
    }

    /**
     * http get object
     *
     * @param path http get path
     * @return default return type class JsonNode
     */
    default Mono<JsonNode> get(String path) {
        return get(path, null);
    }

    /**
     * http get flux object
     *
     * @param path http get path
     * @return default return type class JsonNode
     */
    default Flux<JsonNode> getFlux(String path) {
        return getFlux(path, null);
    }

}
